/*************************************************************************
> File Name: MyTree.h
> Author: icebear
> Mail: 3322366195@qq.com
> Created Time: 2024-08-17 22:27:01
> Description:
************************************************************************/

#ifndef _MYTREE_H_
#define _MYTREE_H_

#include "GlobalValue.h"

namespace ib
{

    /**
     * @brief
     * size 0x20
     */
    class MyRBTreeNodeBase
    {
        enum class NodeColor
        {
            red = false,
            black = true
        };

    public:
        NodeColor node_color_0x0;
        MyRBTreeNodeBase *node_parent_p_0x8;
        MyRBTreeNodeBase *node_left_p_0x10;
        MyRBTreeNodeBase *node_right_p_0x18;
    };

    /**
     * @brief
     * size 0x8
     * @tparam Keycompare 暂时未知
     */
    template <typename Keycompare>
    class MyRBTreeKeyCompare
    {
    public:
        Keycompare cmp_0x0; // 猜测其为函数指针
    };

    /**
     * @brief 0x28
     */
    class MyTreeHeader
    {
    public:
        MyRBTreeNodeBase head_node_0x0;
        size_type head_count_0x8;
    };

    /**
     * @brief
     * size 0x20+sizeof(val)
     * @tparam val 存储对象的类型
     */
    template <typename val>
    class MyTreeNode : public MyRBTreeNodeBase
    {
    public:
        MemBuf<val> storge_0x20;
    };

    /**
     * @brief
     * size: 0x48
     */
    template <typename _Key, typename _Val, typename _KeyOfVal, typename KeyCompare>
    class MyRBTree
    {
        /**
         * @brief
         * size 0x18
         */
        class MyTreeReuseOrAllocNode
        {
            typedef MyRBTreeNodeBase NodeBase;
            typedef MyRBTree RBTree;

        public:
            NodeBase *node_root_p_0x0;
            NodeBase *node_node_p_0x8;
            RBTree &rbtree_tree_ref_0x10;
        };
        /**
         * @brief size 0x48
         * @tparam KeyCompare
         */
        // template <typename KeyCompare>
        class MyRBTreeImpl : public MyTreeReuseOrAllocNode,
                             public MyRBTreeKeyCompare<KeyCompare>,
                             public MyTreeHeader
        {
        };

    protected:
        MyRBTreeImpl rbTree_impl_0x0;
    };

} // namespace ib
#endif
